package manyAnimal;

public class Cat extends Animal implements Terrestrial {
    private int legNum;
    public Cat(String name,int legNum) {
        super(name);
        this.legNum = legNum;
    }

    public void setLegNum(int legNum) throws illegalLegNumException {
        if (legNum<4||legNum>4){
            throw new illegalLegNumException("猫腿4条");
        }else {
            this.legNum = legNum;
        }
    }

    @Override
    public int getLegNum() {
        return legNum;
    }

    @Override
    public String shout() {
       return "我们一起学猫叫,一起喵喵喵喵喵~";
    }

    public void show(){
        System.out.println(this.getName()+"\t\t\t"+this.getLegNum()+"\t\t\t"+shout());
    }


}
